package views.menu;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;

import views.Screen;
import controllers.Game;
import controllers.GamePanel;

@SuppressWarnings("serial")
public class MainMenu extends Menu{
	
	
	private ImageIcon image = new ImageIcon(getClass().getResource("/ConfGameButtonTest.png"));
	//TODO Change the imageButton
	private JButton newGameButton = new JButton(image);
	private JButton generateMapButton = new JButton(image);
	private JButton instructionsButton = new JButton(image);
	private JButton aboutUsButton = new JButton(image);
	
	private Image imageBg = new ImageIcon(getClass().getResource("/BackgroundMenuTest.png")).getImage();
	
	
	public MainMenu() {
		
	}
	
	@Override
	public void paint(Graphics g) {
		g.drawImage(imageBg,0,0,Game.WIDTH,Game.HEIGHT,this);
		
		setOpaque(false);
		super.paint(g);
	}
	
	public void main() {
		
		this.addElements();
		frame.addAsPanel(this);
		
		
	}

	private void addElements() {
		
		final MainMenu mm = this;
		this.setLayout(null);
		this.add(newGameButton);
		this.add(generateMapButton);
		
		newGameButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				frame.getContentPane().remove(mm);
				GamePanel gp = new GamePanel(6, 30, 1, frame);
				gp.main();
				
			}
		});
		newGameButton.setContentAreaFilled(false);
		newGameButton.setBorderPainted(false);
		newGameButton.setBounds(0, 0, 328, 62);
		
		//TODO Move the button into the right position
		generateMapButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				
				MenuGenerateMap mg = new MenuGenerateMap();
				frame.getContentPane().remove(mm);
				
				mg.main();
				
				
			}
		});
			
		generateMapButton.setContentAreaFilled(false);
		generateMapButton.setBorderPainted(false);
		generateMapButton.setBounds(230, 157, 328, 62);
		
		
		
	}
		
}
